/**    
* @Title: EngineStartListener.java
* @Package: org.vdalf.gsgz.service
* @author vDalf 2020-09-26 18:02:43 下午6:02:43
* @Copyright © 2020 vDalf Block-Chain Foundation (In Preparation Non-Governmental Organization) All rights reserved.
*/
package org.vdalf.gsgz.listener;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.vdalf.gsgz.api.impl.OkexRestApi;
import org.vdalf.gsgz.api.impl.OkexWebsocketApi;
import org.vdalf.gsgz.entities.UserData;
import org.vdalf.gsgz.service.PlanEntrustEngine;

/**    
* @Title: EngineStartListener.java
* @Package: org.vdalf.gsgz.service
* @Description: 
* @author vDalf 2020-09-26 18:02:43 下午6:02:43
*/
@Component
public class EngineStartListener implements ApplicationRunner,Ordered{
	
	private static final Logger logger = LoggerFactory.getLogger(EngineStartListener.class);

	@Autowired
	private OkexWebsocketApi okexWebsocketApi;
	
	@Autowired
	private OkexRestApi okexRestApi;
	
	@Override
	public void run(ApplicationArguments args) throws Exception {
		logger.info("engine start.......");
		okexWebsocketApi.initChannels(UserData.getInstance().getPlanEntrusts().keySet());
		okexWebsocketApi.open();
		new PlanEntrustEngine(okexRestApi).start();
	}
	
	@Override
	public int getOrder() {
		return 5;
	}

}
